package com.dog.basics.admin.controller.mtkj;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.admin.mtkj.LockPassAddDto;
import com.dog.basics.bean.dto.admin.mtkj.LockPassFromDto;
import com.dog.basics.bean.vo.admin.mtkj.LockPassVo;
import com.dog.basics.common.annotation.SysLog;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.service.mtkj.IMtDeviceLockPassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;

/**
 * <p>
 * 设备锁通道表 前端控制器
 * </p>
 *
 * @author wph
 * @since 2020-09-30
 */
@RestController
@RequestMapping("/pc/device/lock/pass")
@Api(value = "设备锁通道模块", tags = "设备锁通道模块")
@AllArgsConstructor
public class MtDeviceLockPassController {
    private final IMtDeviceLockPassService mtDeviceLockPassService;

    /**
     * @Description: 设备锁通道列表
     * @Param: LockPassFromDto
     * @return: IPage<LockPassVo>
     * @Author: wph
     * @Date:
     */
    @ApiOperation(value = "设备锁通道列表", notes = "pc:mtDeviceLockPass:page")
    @GetMapping("/page")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceLockPass:page')")
    public R<IPage<LockPassVo>> page(PageParam page, LockPassFromDto obj) {
        return R.ok(mtDeviceLockPassService.getPageList(page, obj));
    }

    /**
     * @Description: 增加医院轮椅关联
     * @Param: HospitalWheelchairAddDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("增加设备锁通道轮椅关联")
    @ApiOperation(value = "增加设备锁通道轮椅关联", notes = "pc:mtDeviceLockPass:save")
    @PostMapping("/save")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceLockPass:save')")
    public R<Boolean> save(@Valid @RequestBody LockPassAddDto obj) {
        return R.ok(mtDeviceLockPassService.saveObj(obj));
    }

    /**
     * @Description: 删除医院轮椅关联
     * @Param: ids
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("删除设备锁通道轮椅关联")
    @ApiOperation(value = "删除设备锁通道轮椅关联", notes = "pc:mtDeviceLockPass:delete")
    @ApiImplicitParam(value = "设备锁通道Id", name = "id", dataType = "Long", required = true)
    @DeleteMapping("/delete/{id}")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceLockPass:delete')")
    public R<Boolean> delete(@PathVariable("id") Long id) {
        return R.ok(mtDeviceLockPassService.deleteObj(id));
    }

    /**
     * @Description: 修改医院轮椅关联
     * @Param: HospitalWheelchairEditDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/19  0027
     */
    @SysLog("修改设备锁通道轮椅关联")
    @ApiOperation(value = "修改设备锁通道轮椅关联", notes = "pc:mtDeviceLockPass:edit")
    @PutMapping("/edit")
    @PreAuthorize("@pms.hasPermission('pc:mtDeviceLockPass:edit')")
    public R<Boolean> edit(@Valid @RequestBody LockPassAddDto obj) {
        return R.ok(mtDeviceLockPassService.editObj(obj));
    }
}
